/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Missiles;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.Rectangle;
import javax.swing.ImageIcon;
import javax.swing.JPanel;

/**
 * Autores:
 * Hugo Hiroshi Yamamura
 * Marina Coimbra Viviani
 * 
 * Classe Missile
 * Classe-pai de todos os mísseis.
 * 
 */
public class Missile {

    private int x, y;
    private Image image;
    boolean visible;
    private int width, height;

    private final int BOARD_WIDTH = 640;
    private final int MISSILE_SPEED = 2;
    
    private int type;

    
        /*
    * 
    * Construtor: Missile
    * @param: coordenada x na qual deseja-se inserir o missil
    * @param2: coordanada y na qual deseja-se inserir o missil
    */   
    public Missile(int x, int y) {

        ImageIcon ii =
            new ImageIcon(this.getClass().getResource("/Sprites/Ball-PokeBall.gif"));
        image = ii.getImage();
        visible = true;
        width = image.getWidth(null);
        height = image.getHeight(null);
        this.x = x;
        this.y = y;
    }

   

         /*
    * 
    * Metodo: getBounds
    * Funcionamento: Cria um retangulo em torno da figura para colisao.
     * @return o retangulo
    */
    public Rectangle getBounds() {
        return new Rectangle(x, y, width, height);
    }
    
         /*
    * 
    * Metodo: paint
    * Funcionamento: pinta o missil no JPanel.
    */
    public void paint(Graphics g, JPanel panel){
        if(this.isVisible()){
            Graphics2D g2d = (Graphics2D)g;
            g2d.drawImage(this.getImage(), this.getX(), this.getY(), panel);
        }
    }

    /*
     * Método move
     * Funcionamento: move o missil na direcao x.
     * 
     */
    public void move() {
        x += MISSILE_SPEED;
        if (x > BOARD_WIDTH)
            visible = false;
    }
    
    /*
     * Getters e Setters
     * 
     */
    public Image getImage() {
        return image;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

   
    public void setHeight(int height) {
        this.height = height;
    }

    public void setImage(Image image) {
        this.image = image;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public void setX(int x) {
        this.x = x;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getHeight() {
        return height;
    }

    public int getWidth() {
        return width;
    }
    
        public int getType() {
        return type;
    }
    
    
     public boolean isVisible() {
        return visible;
    }

    public void setVisible(Boolean visible) {
        this.visible = visible;
    }
    
    
}
